package edu.cornell.cs4740.qa;

import java.util.ArrayList;
import java.util.List;

public class Sentence {
  private List<WordContainer> words;

  public Sentence() {
    words = new ArrayList<WordContainer>();
  }

  public Sentence(WordContainer firstWord) {
    this();
    words.add(firstWord);
  }

  public Sentence(List<WordContainer> allWords) {
    words = allWords;
  }

  public void addWord(WordContainer nextWord) {
    words.add(nextWord);
  }

  public void addAllWords(List<WordContainer> allWords) {
    words = allWords;
  }

  public int getLength() {
    return words.size();
  }

  public WordContainer getWord(int i) {
    if (i < words.size()) {
      return words.get(i);
    }
    return null;
  }

  public List<WordContainer> getAllWords() {
    return words;
  }
  
  public String toString(int maxWords){
	  String s = "";
	  int iMax = Math.min(maxWords, words.size());
	  for(int i=0;i<iMax;i++){
		  s+=(words.get(i).getWord()+" ");
	  }
	  return s;
  }
}
